﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TinTuc_List.ascx.cs" Inherits="cbmobile.UserControl.TinTuc_List" %>
<%@ Register Assembly="PQT.Controls" Namespace="PQT.Controls" TagPrefix="pqt" %>
<script type="text/javascript">


    function CheckAndConfirmDelete()
    {   
    
        var strValueIDChecked = '';
        
        var arrChkItem = document.getElementsByName('chkItem');
        
        for(var i=0; i< arrChkItem.length; i++)
        {
            var chkItem = arrChkItem[i];
            if(chkItem.checked == true)
            {
                strValueIDChecked += chkItem.value + '|';
            }
            
        }
        
        if(strValueIDChecked == '')
        {
            alert("Vui lòng chọn sản phẩm cần xóa");
            return false;
        }
        else
        {
            if(confirm('Bạn có chắc xóa các sản phẩm này không?'))
            {
                var hdnIDs = document.getElementById('<%=hdnIDs.ClientID %>');
                hdnIDs.value  = strValueIDChecked;
                return true;   
            }
            else
                return false;
        
        }
    }  

    function CheckAllItem(objcheckAll)
    {
        var obj = document.getElementsByName('chkItem');
        
        for(var i=0; i< obj.length; i++)
        {
            var chkItem = obj[i];
            chkItem.checked = objcheckAll.checked;
        }
    }

    function CheckActive()
    {   
    
        var strValueIDChecked = '';
        
        var arrChkItem = document.getElementsByName('chkItem');
        
        for(var i=0; i< arrChkItem.length; i++)
        {
            var chkItem = arrChkItem[i];
            if(chkItem.checked == true)
            {
                strValueIDChecked += chkItem.value + '|';
            }
            
        }
        
        if(strValueIDChecked == '')
        {
            alert("Vui lòng chọn tin cần cập nhật cho hiển thị tin");
            return false;
        }
        else
        {
            var hdnIDs = document.getElementById('<%=hdnIDs.ClientID %>');
            hdnIDs.value  = strValueIDChecked;
            return true;   
        
        }
    
    }
</script>

<asp:HiddenField ID="hdnIDs" Value="" runat="server" />

<div class="sb-box">
    <div class="header">
        <h3>
            Danh sách bài viết
        </h3>
        <a href="/RenderMain.aspx?muid=TinTuc_Entry&action=addnew"
            class="button small">
            <span>Insert</span>
        </a>
        &nbsp;&nbsp;
        <asp:LinkButton ID="btnDelete" runat="server" OnClientClick="return CheckAndConfirmDelete();"
            Text="Xóa" CssClass="button small" onclick="btnDelete_Click">
                                            <span>Xóa</span>
        </asp:LinkButton>&nbsp;&nbsp;
        </div>
    <div class=" clear">
    </div>
    <div class="bcont">
        <div class="search_box pdT10" align="center">
            <table cellpadding="0" cellspacing="0">
                <tr class="trLabelFilter1">
                    <td>
                        Tìm kiếm:
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlStatus" runat="server" CssClass="select small" Width="150px">
                            <asp:ListItem Text="Chọn trạng thái" Value="2"></asp:ListItem>
                            <asp:ListItem Text="True" Value="1"></asp:ListItem>
                            <asp:ListItem Text="False" Value="0"></asp:ListItem>
                        </asp:DropDownList>
                        <asp:DropDownList ID="ddlCategory" Width="200px" Visible="false" CssClass="select small"
                            runat="server">
                        </asp:DropDownList>
                        <asp:DropDownList ID="ddlSearchType" Visible="false" runat="server">
                            <asp:ListItem Text="All" Value="0"></asp:ListItem>
                            <asp:ListItem Text="Title" Value="1"></asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td>
                        &nbsp;
                        <asp:TextBox ID="txtSearchText" onkeydown="return SetFocusOnEnter(event, 'btnSearch');"
                            runat="server" CssClass="inputtext small"></asp:TextBox>
                    </td>
                    <td>
                        <asp:LinkButton ID="btnSearch" runat="server" CssClass="button small" 
                            onclick="btnSearch_Click">
                                            <span>Tìm kiếm</span>
                            
                        </asp:LinkButton>
                    </td>
                </tr>
            </table>
        </div>
        <div class=" clear">
        </div>
        <asp:GridView ID="gvList" runat="server" Width="100%" AutoGenerateColumns="False"
             AlternatingRowStyle-CssClass="bg" CssClass="infotable" onrowcommand="gvList_RowCommand" 
           >
<AlternatingRowStyle CssClass="bg"></AlternatingRowStyle>
            <Columns>
                <asp:TemplateField HeaderText="#">
                    <HeaderTemplate>
                        <input id="chkAll" type="checkbox" onclick="CheckAllItem(this);" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <input id="chkItem" type="checkbox" name="chkItem" value='<%# Eval("ID_News")%>' />
                    </ItemTemplate>
                    <HeaderStyle Width="5%" CssClass="RB_L" HorizontalAlign="center" />
                    <ItemStyle CssClass="RB_L" Width="50px" HorizontalAlign="Center" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="STT">
                    <ItemTemplate>
                    &nbsp
                       <asp:Label ID="lblSTT" CssClass="text002" Text='<%# Eval("ID_News")%>' runat="server" />
                    </ItemTemplate>
                    <HeaderStyle Width="50px" CssClass="RB_L" HorizontalAlign="center" />
                    <ItemStyle CssClass="RB_L" Width="8%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Tiêu đề">
                    <ItemTemplate>
                        <asp:LinkButton  ID="lnkLink" runat="server" 
                            CommandArgument='<%# Eval("ID_News") %>' CommandName="edit" Text='<%# Eval("TieuDe") %>' 
                            onclick="lnkLink_Click"></asp:LinkButton>
                    </ItemTemplate>
                    <HeaderStyle CssClass="RB_L" HorizontalAlign="Center" />
                    <ItemStyle CssClass="L" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Ngày tạo">
                    <ItemTemplate>
                    &nbsp;
                        <asp:Label ID="lblNgayTao" runat="server" Text='<%# Eval("NgayTao", "{0: yyyy-MM-dd}")%>' />
                            &nbsp;
                    </ItemTemplate>
                    <HeaderStyle CssClass="RB_L" HorizontalAlign="Center" Width="17%" />
                    <ItemStyle CssClass="RB_L" Width="20%" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Trạng thái">
                    <ItemTemplate>
                    &nbsp;
                        <asp:Label ID="Label1421" runat="server" Text='<%#GetStatusName(Eval("TrangThai"))%>' />
                        &nbsp;
                    </ItemTemplate>
                    <HeaderStyle CssClass="RB_L" HorizontalAlign="Center" Width="17%" />
                    <ItemStyle CssClass="B_L" Width="20%" />
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <br />
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td width="200px">
                </td>
                <td class="C">
                    <pqt:PQTPager ID="PQTPager1" runat="server"
                        Width="410px" />
                </td>
                <td width="200px" class="R">
                    <asp:TextBox ID="txtCurrentPage" runat="server" Width="30px" Style="text-align: right"
                        CssClass="Input_text"></asp:TextBox>
                    /<asp:Label ID="lblTotalPage" runat="server" Text=""></asp:Label>
                    <asp:Label ID="Label2" runat="server" Text=" Page"></asp:Label>
                    &nbsp;&nbsp;
                    <asp:Button ID="btnPageMove" runat="server" Text="Move" Font-Bold="true" 
                         Style="background: url('Images/Icon/btn_move.gif') no-repeat left;
                        padding-bottom: 3px; padding-left: 22px;" />
                </td>
            </tr>
        </table>
    </div>
</div>

